package priv.pront.code.lanqiao.competition.course.date0330;

import java.util.*;

public class 统计子矩阵 {
    static int N = 510;
    static int[][] a = new int[N][N];
    static int[][] s = new int[N][N];
    static int n, m, k;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        //前缀和
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = sc.nextInt();
                s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
            }
        }
        long res = 0;
        //枚举上下边界
        for (int up = 1; up <= n; up++) {
            for (int down = up; down <= n; down++) {
                int left = 1;
                int right = 1;
                while (right <= m) {
                    //右边界在整个矩阵内
                    while (left <= right && !check(up, left, down, right)){
                        left++;
                    }
                    res += (long) right - left + 1;
                    right++;
                }

            }
        }
        System.out.println(res);
    }

    static boolean check(int x1, int y1, int x2, int y2) {
        //该位置数的限制
        long sum = s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];
        return sum <= k;
    }
}
